<div class="layuimini-main">

    <div class="layui-form layuimini-form" >

        <div class="layui-form-item">
            <label class="layui-form-label required">报修类型</label>
            <div class="layui-input-block">
                <select name="comId" lay-verify="required"  id="typeId2" lay-search="">
                    <option value="">请选择报修类型</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">phone</label>
            <div class="layui-input-block">
                <input type="text" name="phone" lay-verify="required" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">期望时间</label>
            <div class="layui-input-block">
                <input type="text" name="hopeDate" class="layui-input" id="test5" placeholder="请选择报修时间">
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label required" >报修内容</label>
            <div class="layui-input-block">
                <textarea name="remarks" class="layui-textarea" lay-verify="required" placeholder="请输入报修内容"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'table'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            $ = layui.$;

        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        //获取费用类型 并渲染数据到select标签
        $.get("repair/queryAll",{},function (data) {
            var list=data;
            var select =document.getElementById("typeId2");
            if(list!=null || list.size()>0){
                for(var c in list){
                    var option=document.createElement("option");
                    option.setAttribute("value",list[c].id);
                    option.innerText=list[c].name;
                    select.appendChild(option);
                }
            }
            form.render('select');
        },"json");

        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            //获取表单中的数据信息
            var datas=data.field;
            addOrUpdateSubmit($,"repair/add",datas);
            return false;
        });

    });
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        //日期时间选择器
        laydate.render({
            elem: '#test5'
            ,type: 'datetime'
        });
    })
</script>